﻿using BW.MesProject.Production.Domain.Dto.Input.WorkProcess;
using BW.MesProject.Production.Domain.Dto.Output.WorkProess;
using BW.MesProject.Production.Domain.Model;
using BW.MesProject.Production.Infrastructure;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.Production.Host.Controllers
{
    /// <summary>
    /// 工单工序表
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WorkProcessController : ControllerBase
    {
        private readonly IWorkProcessServices _workProcessServices;

        public WorkProcessController(IWorkProcessServices workProcessServices)
        {
            _workProcessServices = workProcessServices;
        }
        /// <summary>
        /// 获取工序
        /// </summary>
        /// <param name="WorkOrderCode"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<WorkProessOutput>> GetWorkProessList([FromQuery] string WorkOrderCode)
        {
            return _workProcessServices.GetWorkProessList(WorkOrderCode);
        }
        /// <summary>
        /// 获取工序
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<WorkProessOutput> GetWorkProess(decimal Id)
        {
            return _workProcessServices.GetWorkProess(Id);
        }
        /// <summary>
        /// 开始工序
        /// </summary>
        /// <param name="DateTime"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> StartWorkProess(string DateTime, decimal Id)
        {
            return _workProcessServices.StartWorkProess(DateTime, Id);
        }
        /// <summary>
        /// 新增产出
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateWorkProess(WorkPorcessInput input)
        {
            return _workProcessServices.UpdateWorkProess(input);
        }
        [HttpGet]
        public ApiResult<List<WORKPROESSMODEL>> GetWorkProesss()
        {
            return _workProcessServices.GetWorkProesss();
        }
    }
}
